package com.itheima.dubbo.service;


import com.itheima.dubbo.DubboClient;
import com.itheima.dubbo.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Value;

//@DubboService //标识 服务提供方 注解
//@DubboService(timeout = 1900)//提供方接口级别配置
//@DubboService(methods = {
//        @Method(name="getUserById", timeout = 1900, retries = 0)
//})  //提供方方法级别配置
@DubboService(version = "${dubbo.application.version}")
public class ProducerImpl implements DubboClient {


    @Override
    public String hello(String userName) {
        return "Hello Dubbo UserName："+userName;
    }

    @Value("${server.port}")
    private Integer port;


    @Override
    public User getUserById(User user) {
        User userResult = new User(user.getId(), "张三", 80);

//        System.out.println("方法执行。。。1.0.0");

        System.out.println("UserFaceImpl getById is run....." + port);

        String str = RpcContext.getContext().getAttachment("itname");
        System.out.println(str);

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return userResult;
    }
}
